using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProduceBasicData.Domain.Entities;
using ProduceBasicData.Domain.Inventories;

namespace ProduceBasicData.Domain.Material
{
    /// <summary>
    /// 物料群组实体
    /// </summary>
    public class MaterialGroupModel : BaseModel
    {
        /// <summary>
        /// 系统编码
        /// </summary>
        public string? MaterialNo { get; set; }
        
        /// <summary>
        /// 名称
        /// </summary>
        public string MaterialName { get; set; }
        
        /// <summary>
        /// 群组类型ID（关联GroupTypeDictionary）
        /// </summary>
        public int GroupTypeId { get; set; }
        
        /// <summary>
        /// 群组类型名称（冗余字段，便于查询）
        /// </summary>
        public string GroupType { get; set; }
        
        /// <summary>
        /// 群组类型导航属性
        /// </summary>
        [ForeignKey("GroupTypeId")]
        public virtual GroupTypeDictionary GroupTypeDict { get; set; }
        
        /// <summary>
        /// 群组ID
        /// </summary>
        public int? GroupId { get; set; }
        
        /// <summary>
        /// 群组名称
        /// </summary>
        public string GroupName { get; set; }
        
        /// <summary>
        /// 默认工艺路线ID（关联CraftModel）
        /// </summary>
        public int? DefaultCraftId { get; set; }
        
        /// <summary>
        /// 默认工艺路线名称（冗余字段，便于查询）
        /// </summary>
        public string DefaultCraftName { get; set; }
        
        /// <summary>
        /// 默认工艺路线导航属性
        /// </summary>
        [ForeignKey("DefaultCraftId")]
        public virtual CraftModel DefaultCraft { get; set; }
        
        /// <summary>
        /// 描述
        /// </summary>
        public string MaterialDesc { get; set; }
        
        /// <summary>
        /// 是否显示默认工艺路线（只有半成品和成品时显示）
        /// </summary>
        [NotMapped]
        public bool ShowDefaultCraft => GroupType == "半成品" || GroupType == "成品";
    }
}